package com.ryqg.jiaofu.domain.pagequery.pdfinfo;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

@Getter
@AllArgsConstructor
public enum TimeRangeEnum {
    ALL("all", "全部"),
    WEEK("week", "近一周"),
    MONTH("month", "近一月"),
    QUARTER("quarter", "近三月");

    private final String code;
    private final String desc;

    public static TimeRangeEnum fromCode(String code) {
        return Arrays.stream(values())
                .filter(e -> e.getCode().equals(code))
                .findFirst()
                .orElse(ALL);
    }

    @Override
    public String toString() {
        return this.code;
    }
}
